package com.zpark;

import com.zpark.convert.UserConvert;
import com.zpark.dto.PersonDto;
import com.zpark.dto.UserDto;
import com.zpark.entity.User;

import java.util.ArrayList;
import java.util.List;

/**
 * @PackageName: com.zpark
 * @ClassName: TestMain
 * @Description:
 * @author: RZS
 * @date: 2024/5/13  9:05
 */
public class TestMain {
    public static void main(String[] args) {
        // 实例化User对象
        User user = new User();
        user.setId(1001);
        user.setUsername("大锤");
        user.setPassword("123456");
        user.setPhone("13656564848");

        // 对象转换  user -> userDto
        UserDto dto = UserConvert.INSTANCE.userToUserDto(user);

        System.out.println(dto);

        dto.setUsername("张三");
        dto.setPassword("666666");

        // 将dto转为user对象
        User user1 = UserConvert.INSTANCE.userDtoToUser(dto);
        System.out.println(user1);

        List<User> users = new ArrayList<>();
        users.add(user);
        users.add(user1);

        // 将List<User> 转换为 List<UserDto>
        List<UserDto> userDtos = UserConvert.INSTANCE.ltUserToLtDto(users);

        System.out.println(userDtos);

        System.out.println("*******************************************");

        // 将User对象转为PersonDto
        PersonDto personDto = UserConvert.INSTANCE.userToPersonDto(user);
        System.out.println(personDto);

    }
}
